#include <bits/stdc++.h>
using namespace std;
int main() {
	int a[5];
	int num[5];
	int i;
	int sum=0;
	for(i=0;i<=4;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<=4;i++){
		sum = sum+a[i]%3;
		if(i == 0){
			
			a[i]=a[i]/3;
			a[i+1]+=a[i];
			a[4]+=a[i];
		}
		else if(i==4){
			a[4]=a[4]/3;
			a[0]+=a[4];
			a[i-1]+=a[4];
		}
		else if(i>0&&i<4){
		
			a[i]=a[i]/3;
			a[i+1]+=a[i];
			a[i-1]+=a[i];
		}
	}
	
	
	for(i=0;i<=4;i++){
		printf("%d ",a[i]);
	}
	printf("\n%d",sum);
	return 0;
}
